package com.jh3502.vivo.function.messagedetail;

import com.jh3502.vivo.base.BaseCallback;
import com.jh3502.vivo.base.BaseJson;
import com.jh3502.vivo.base.BasePresenter;
import com.jh3502.vivo.base.BaseView;
import com.jh3502.vivo.utils.Utils;

import java.util.Map;

/**
 * @author harisucici
 * @date 2017/6/19
 */

public class MessageDetailPresenter extends BasePresenter<MessageDetailPresenter.MessageDetailView> {
    MessageDetailModel mMessageDetailModel;

    MessageDetailView mMessageDetailView;


    public void setMessageDetailView(MessageDetailView mMessageDetailView) {
        this.mMessageDetailView = mMessageDetailView;
    }


    public void toFindMsgRecords(Map<String, Object> body) {
        mMessageDetailView.showLoadingDialog();
        if (mMessageDetailModel == null) {
            mMessageDetailModel = new MessageDetailModel(mMessageDetailView.getActContext());
        }

        mMessageDetailModel.findMsgRecords(body, new BaseCallback(mMessageDetailView) {
            @Override
            public void responseSuccess(BaseJson baseJson) {
                mMessageDetailView.findMsgRecordsSuccess(Utils.getInstance().jso2map(baseJson.getObj().toString()));
            }
        });
    }


    @Override
    public void cancelCall() {

    }

    public interface MessageDetailView extends BaseView {
        void findMsgRecordsSuccess(Map<String, Object> maps);
    }
}
